package org.mc.utils;

import lombok.Data;
import org.mc.common.util.JSONUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by luoxf on 2018/4/23.
 */
public enum UploadFileEnum {

    FILE_NAME("fileName"),
    FILE_PATH("filePath"),
    IS_DEL("isDel");

    private String name;

    UploadFileEnum(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //覆盖方法
    @Override
    public String toString() {
        return this.name;
    }

    public static String setFile(String nameValue, String pathValue) {
        Map map = new HashMap();
        map.put(UploadFileEnum.FILE_NAME.toString(), nameValue);
        map.put(UploadFileEnum.FILE_PATH.toString(), pathValue);
        return JSONUtils.toJson(map);
    }

    @Data
    class FileBean {
        private String fileName;
        private String filePath;
    }

    public static void main(String[] agrn) {
        String obj = UploadFileEnum.setFile("1111", "/oss/path/");
        System.out.println(obj);
        System.out.println(JSONUtils.toBean(obj, FileBean.class));
    }
}
